<template>
  <div class="u-p-20">
    <el-card shadow="never">
      <div slot="header">
        <b class="u-f-16">
          <span v-if="objForm.id">编辑</span>
          <span v-else>添加</span>关键词
        </b>
        <div class="u-right u-5mt">
          <el-button
            type="success"
            size="small"
            icon="el-icon-document-checked"
            @click="submitForm('objForm')"
            v-if="hasPerm('keywordEditPost')"
          >提交保存</el-button>
          <el-button size="small" icon="el-icon-back" @click="$router.go(-1)">返回</el-button>
        </div>
      </div>
      <el-form :model="objForm" :rules="rules" ref="objForm" label-width="100px" class="u-form">
        <el-form-item label="关键词">
          <el-input v-model="objForm.keyword" placeholder="请输入关键词"></el-input>
        </el-form-item>
        <el-form-item label="是否上线">
            <el-switch
              v-model="objForm.status"
              active-color="#13ce66"
              :active-value="1"
              inactive-color="#666"
              :inactive-value="2"
            ></el-switch>
        </el-form-item>
        <el-form-item label="搜索次数">
          <el-input-number v-model="objForm.shearch_count" :min="0" label="搜索次数"></el-input-number>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import commonEdit from "@/mixins/common-edit";
export default {
  mixins: [commonEdit],
  data() {
    return {
      apiName: "keyword",
      backRoute: "keywordIndex", //成功跳转地址
      objForm: {
        id: "",
        type:1,
        status:2,
        keyword: "", //关键词
        shearch_count: 0
      }
    };
  },
  methods: {},
  created() {
    if (this.$route.params.id) {
      this.objForm.id = this.$route.params.id;
    }
  }
};
</script>
